home *** CD-ROM | disk | FTP | other *** search
- ;----------------------------------------------------------------------------
- ; checksum cmos
- ; inputs: dl = ps2 flag 0=not ps2 1=this is a ps2
- ; outputs: al = 0 checksum ok
- ; 1 checksum bad
- ; bx = computed checksum
- ;
- checksum_cmos:
- sub bx,bx
- sub cx,cx
- mov cl,cm10 ;diskette byte offset
- mov ch,cm2e ;checksum high byte
- cmp dl,1 ;check if ps2
- jne cmos2
- mov bx,-1 ;init crc to -1
- mov ch,cm34 ;ps2 end point
-
- cmos2: mov al,cl
-
- push ax
- call read_cmos
- add sp,2 ;fix stack
-
- sub ah,ah
- cmp dl,1 ;check if ps2
- jne norm_cksm
- ;
- ; ps2 crc calc al=raw data bx=crc so far
- ;
- call crc_sum1
- jmp norm_ck_cont
- norm_cksm:
- add bx,ax
- norm_ck_cont:
- inc cl
- cmp ch,cl
- jnz cmos2
- cmp dl,1 ;check if ps/2
- jne normal_checksum
- or bx,bx
- jnz bad_checksum
- ;
- ; check ps/2 checksum
- ;
- mov al,cm32 ;address checksum high
-
- push ax
- call read_cmos
- add sp,2 ;fix stack
-
- mov ah,al
- mov al,cm33 ;address checksum low
-
- push ax
- call read_cmos
- add sp,2 ;fix stack
- mov bx,ax
- sub ax,ax
-
- jmp cmos_ck_exit
-
- normal_checksum:
- or bx,bx
- jz bad_checksum
- mov al,cm2e ;address checksum high
-
- push ax
- call read_cmos
- add sp,2 ;fix stack
-
- mov ah,al
- mov al,cm2f ;address checksum low
-
- push ax
- call read_cmos
- add sp,2 ;fix stack
-
- cmp ax,bx
- jne bad_checksum
- sub ax,ax
- jmp cmos_ck_exit
- bad_checksum:
- mov al,1
- cmos_ck_exit:
- ret
- ;
- ; crc calculation
- ;
- crc_sum1:
- push ax
- push cx
- mov cl,4
- xor bh,al
- mov al,bh
- rol ax,cl
- xor bx,ax
- rol ax,1
- xchg bh,bl
- xor bx,ax
- ror ax,cl
- and al,0e0h
- xor bx,ax
- ror ax,1
- xor bh,al
- pop cx
- pop ax
- ret
-